package com.weifangfirecontrolformal.weifangfirecontrolformal.web.web.check.maintenance;

import cn.hutool.json.JSONObject;
import com.weifangfirecontrolformal.weifangfirecontrolformal.common.base.BaseController;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.annotaion.Action;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.annotaion.At;
import com.weifangfirecontrolformal.weifangfirecontrolformal.support.model.RespEntity;
import com.weifangfirecontrolformal.weifangfirecontrolformal.web.service.check.maintenance.MaintenanceService;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @Author: YangYu
 * @ClassName: MaintenanceController
 * @Date: Created in 16:00 2022/8/24
 * @Description: 维保控制器
 */
@Action
@RequestMapping(value="check/maintenance")
public class MaintenanceController extends BaseController {
    @Resource
    MaintenanceService maintenanceService;


    /**
     * @Author YangYu
     * @Description 分区树列表
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "partitionTreeList", method = RequestMethod.GET)
    public RespEntity inspectionPlanDetail(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.partitionTreeList(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 分区新增、编辑
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "partitionAddOrUpdate", method = RequestMethod.POST)
    public RespEntity partitionAddOrUpdate(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.partitionAddOrUpdate(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 分区删除
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "partitionDel", method = RequestMethod.POST)
    public RespEntity partitionDel(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.partitionDel(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 维保设备分页列表
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "deviceListPage", method = RequestMethod.GET, param = { "page","limit"})
    public RespEntity deviceListPage(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.deviceListPage(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 设备新增、更新
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "deviceAddOrUpdate", method = RequestMethod.POST)
    public RespEntity deviceAddOrUpdate(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.deviceAddOrUpdate(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 设备删除
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "deviceDel", method = RequestMethod.POST)
    public RespEntity deviceDel(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.deviceDel(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 任务新增、编辑
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "taskAddOrUpdate", method = RequestMethod.POST)
    public RespEntity taskAddOrUpdate(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.taskAddOrUpdate(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 任务删除
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "taskDel", method = RequestMethod.POST)
    public RespEntity taskDel(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.taskDel(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 任务分页列表
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "taskListPage", method = RequestMethod.GET, param = { "page","limit"})
    public RespEntity taskListPage(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.taskListPage(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 任务指派
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "taskAssignment", method = RequestMethod.POST)
    public RespEntity taskAssignment(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.taskAssignment(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 更新任务状态
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "updateState", method = RequestMethod.POST)
    public RespEntity updateState(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.updateState(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 任务书详情（维保部件详情）
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "maintenanceBookDetail", method = RequestMethod.GET)
    public RespEntity maintenanceBookDetail(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.maintenanceBookDetail(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 维保报告数据
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "maintenanceReport", method = RequestMethod.GET)
    public RespEntity maintenanceReport(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.maintenanceReport(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 消防设施系统列表
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "maintenanceSystemList", method = RequestMethod.GET)
    public RespEntity maintenanceSystemList(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.maintenanceSystemList(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 设备类型列表
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "maintenanceTypeList", method = RequestMethod.GET)
    public RespEntity maintenanceTypeList(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.maintenanceTypeList(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 设备类型列表
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "maintenanceBookList", method = RequestMethod.GET)
    public RespEntity maintenanceBookList(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.maintenanceBookList(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 更新部件为异常状态
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "updateResult", method = RequestMethod.POST)
    public RespEntity updateResult(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.updateResult(jsonParam);
    }

    /**
     * @Author YangYu
     * @Description 维保报告导出
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "reportExport", method = RequestMethod.GET,param = { "cycle","startTime","endTime"})
    public RespEntity reportExport(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.reportExport(jsonParam);
    }

    /**
     * 设备导入模板下载
     * @param map
     * @return
     * @throws Exception
     */
    @At(value = "getTemplate", method = RequestMethod.GET)
    public ResponseEntity<byte[]> getTemplate(@RequestParam Map<String,Object> map) throws Exception {
        return maintenanceService.getTemplate(request);
    }

    /**
     * @Author YangYu
     * @Description 恢复分区下的设备状态为未检测
     * @Date Created in 10:09 2022/8/25
     * @Param [jsonParam]
     */

    @At(value = "updateDeviceState", method = RequestMethod.POST)
    public RespEntity updateDeviceState(@RequestBody(required = false) JSONObject jsonParam) {
        return maintenanceService.updateDeviceState(jsonParam);
    }

}
